<template>
  <div class="baobei-finish">
    <section class="wboxnoborder">

          <div v-show="loading">加载中...</div>
          <el-form ref="form"
            v-show="!loading"
            label-width="150px"
            label-position="right">
            <el-form-item label="征求意见单位">
              <span class="selectioncontent">
                {{JSON.parse(fdata.sendRecord).UnitName}}
              </span>
            </el-form-item>
            <el-form-item label="征求意见时间">
              <span class="selectioncontent">
                {{JSON.parse(fdata.sendRecord).sendTime}}
              </span>
            </el-form-item>
            <el-form-item label="征求意见函文号">
              <span class="selectioncontent">
                {{JSON.parse(fdata.sendRecord).sendNum}}
              </span>
            </el-form-item>
            <el-form-item label="复函时间">
              <span class="selectioncontent">
                {{JSON.parse(fdata.receiveRecord).receiveTime}}
              </span>
            </el-form-item>
            <el-form-item label="复函文号">
              <span class="selectioncontent">
                {{JSON.parse(fdata.receiveRecord).receiveNum}}
              </span>
            </el-form-item>
            <el-form-item label="反馈结果">
              <span class="selectioncontent">
                {{JSON.parse(fdata.receiveRecord).receiveContent}}
              </span>
            </el-form-item>
            <el-form-item label="是否同意">
              <span class="selectioncontent">
                <template v-if="fdata.passed===1">是</template>
                <template v-else-if="fdata.passed===0">否</template>
              </span>
            </el-form-item>
            <el-form-item label="附件">
              <el-link
                v-for="item of fdata.files"
                :key="item.id"
                type="primary"
                :href="$http.defaults.baseURL+$http.defaults.selectionAPI+'api/gen/file/download?id='+item.id"
                style="margin-left: 8px;">{{item.fileName}}.{{item.fileType}}</el-link>
            </el-form-item>
            <el-form-item label="备注">
              <span class="selectioncontent">
                {{fdata.remark}}
              </span>
            </el-form-item>
          </el-form>
          <notice :noticePersonId="personId" step="13"></notice>
          <!-- <el-button type="primary" @click="backlist" style="margin: 10px 0 10px 150px">返回</el-button> -->
        <!-- </el-scrollbar>
      </div> -->
    </section>
  </div>
</template>

<script>
import notice from '../common/Notice'
export default {
  props: ['personId'],
  watch: {
    personId: {
      handler (val, oldVal) {
        console.log('newval:' + val)
        if (val) {
          this.showFinishData(val)
        }
      },
      immediate: true
    }
  },
  name: 'manageOpinion-finish',
  data () {
    return {
      loading: false,
      fdata: {}
    }
  },
  components: {
    notice
  },
  mounted () {
    // 获取完成data
    // let pid = this.$route.params.id
    // console.log('人选pid:', pid)
    // this.personId = pid
    // this.showFinishData(pid)
    // // resize
    // this.tableresize(this)
    // let _this = this
    // window.onresize = function windowResize () {
    //   // 通过捕获系统的onresize事件触发我们需要执行的事件
    //   _this.tableresize(_this)
    // }
  },
  methods: {
    // backlist () {
    //   this.$router.push({path: '/selection/'})
    // },
    exportTelRecord (id) {
      let url = this.$http.defaults.selectionAPI + 'api/selection/document/exportDhjlb?batchId=' + id
      // console.log(url)
      this.$http.get(url).then(res => {
        if (res.data.success === true) {
          this.download(res.data.result)
        } else {
          this.$message({
            message: '数据获取失败',
            type: 'error'
          })
        }
      })
      // window.open(this.$http.defaults.baseURL + this.$http.defaults.selectionAPI + 'api/selection/document/exportDhjlb?batchId=' + id)
    },
    download (fileid) {
      var downloadElement = document.createElement('a')
      downloadElement.href = this.$http.defaults.baseURL + this.$http.defaults.selectionAPI + 'api/gen/file/download?id=' + fileid
      document.body.appendChild(downloadElement)
      downloadElement.click() // 点击下载
      document.body.removeChild(downloadElement) // 下载完成移除元素
    },
    showFinishData (pid) {
      this.loading = true
      let url = this.$http.defaults.selectionAPI + 'api/selection/manageOpinion/getBatchByPerson'
      // console.log(url)
      this.$http.get(url, {
        params: {
          personId: pid
        }
      }).then(res => {
        this.loading = false
        console.log('get finish data succ:', res)
        if (res.data.success === true) {
          this.fdata = res.data.result
        } else {
          this.$message({
            message: '数据获取失败',
            type: 'error'
          })
        }
      })
    }
  }
}
</script>

<style>
.baobei-finish .el-form-item{
  margin-bottom:0;
}
.baobei-finish .wboxnoborder .el-table{
  border: #95B8E7 solid 1px;
}
.baobei-finish .wboxnoborder .el-table th{
  font-weight: normal;
  background-image: linear-gradient(to bottom , #f8f8f8, #efefef);
  text-align: center;
  border-right: #95B8E7 solid 1px;
  border-bottom: #95B8E7 solid 1px;
  min-height: 30px;
  line-height:30px;
}
.baobei-finish .wboxnoborder .el-table td, .el-table th{
  padding:0;
  font-size:var(--size14) !important;
  line-height: 20px;
  font-family: '宋体';
  text-align: center;
}
.baobei-finish .el-table__row{
  height: 50px;
}
</style>
<style scoped>
.baobei-finish {
  width: 100%;
}
.tit {
  width: 100%;
  height: 40px;
  line-height: 40px;
  font-size: 16px;
}
.item {
  width: 100%;
  height: 40px;
  display: flex;
  align-items: center;
}
.item-left {
  width: 120px;
  text-align: right;
}
.item-right {
  width: 60%;
  margin-left: 15px;
  font-weight: bolder
}
.line {
  width: 100%;
  height: 1px;
  background-color: #74A6CC;
  margin-top: 20px;
}
.baobei-finish .wboxnoborder {
  padding: 0;
  width: 100%;
  background-color: #fff;
  margin: 0 10px;
  overflow: hidden;
}
</style>
